<?php
class Giangvien extends CI_Controller {
	public $data;
	public function __construct()
	{
		parent::__construct();
        $this->load->model('admin/m_giangvien');
        $this->data['tinyMCE']=true;
        $this->load->model('admin/m_baigiang');
	}
	public function index()
	{
		 $this->data['title']="Trang Giảng Viên.";
        $this->data['giangvien']= $this->m_giangvien->get_select();
        
        $this->load->view('admin/giangvien',$this->data);
        
    }
     public function show()
    {
        $this->data['khoahoc']= $this->m_giangvien->get_select();
        $this->load->view('admin/khoahoc/v_khoahoc',$this->data);
    }
	
    public function insert(){
         
         if(isset($_POST['btnsubmit']) && $_POST['btnsubmit']){
            
           /* $ten = $this->input->post('ten_khoahoc');
            $noidung = $this->input->post('noidung');
            $tl = $this->input->post('thoi_luong');
            $time = $this->input->post('time_start');
            $mon = $this->input->post('mon');
            $giangvien = $this->input->post('giang_vien');
            $nganh = $this->input->post('nganh');*/
            $ten_mon = $this->input->post('ten_mon');
            $nganh = $this->input->post('id_menu');
            $tinchi = $this->input->post('tinchi');
            //if($this->m_giangvien->insertKhoahoc($ten, $noidung, $tl, $time, $mon, $giangvien, $nganh)){
            if($this->m_giangvien->insertmon($ten_mon, $nganh, $tinchi)){
                //Thanh cong
                $this->data['title'] = "Thêm thành công";
                echo "<script>alert('Thêm thành công!!!');</script>";
            }else{
                //False
                $this->data['title'] = "Thêm thất bại";
            }
            $this->load->view('admin/giangvien',$this->data);
         }
    }
    public function delete($id)
    {
        $id = (int)$this->uri->segment(4);
        if($id == ''){
            $this->data['title'] = "ID không hợp lệ";
        }else{
            if($this->m_giangvien->get_delete($id)){
                 $this->data['title'] = "Xóa thành công";
                 echo "<script>alert('Xóa thành công!!!');</script>";
                 
            }else{
                $this->data['title'] = "Hệ thống đang bảo trì";
            }
        }
        
        $this->show();
    }
   }
?>
